<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <base data-ice="baseUrl" href="../../../">
  <title data-ice="title">Iterator | jstreemap Library</title>
  <link type="text/css" rel="stylesheet" href="css/style.css">
  <link type="text/css" rel="stylesheet" href="css/prettify-tomorrow.css">
  <script src="script/prettify/prettify.js"></script>
  <script src="script/manual.js"></script>
<meta name="description" content="Associative containers (sets, maps) library for JavaScript, using red-black trees."><meta property="twitter:card" content="summary"><meta property="twitter:title" content="jstreemap Library"><meta property="twitter:description" content="Associative containers (sets, maps) library for JavaScript, using red-black trees."></head>
<body class="layout-container" data-ice="rootContainer">

<header>
  <a href="./">Home</a>
  
  <a href="identifiers.html">Reference</a>
  <a href="source.html">Source</a>
  
  <div class="search-box">
  <span>
    <img src="./image/search.png">
    <span class="search-input-edge"></span><input class="search-input"><span class="search-input-edge"></span>
  </span>
    <ul class="search-result"></ul>
  </div>
<a style="position:relative; top:3px;" href="https://github.com/Kirusi/jstreemap"><img width="20px" src="./image/github.png"></a></header>

<nav class="navigation" data-ice="nav"><div>
  <ul>
    
  <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#public">public</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/public/insertion-result.js~InsertionResult.html">InsertionResult</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/public/iterators.js~BaseIterator.html">BaseIterator</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/public/iterators.js~Iterator.html">Iterator</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/public/iterators.js~ReverseIterator.html">ReverseIterator</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/public/js-iterators.js~JsIterator.html">JsIterator</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/public/js-iterators.js~JsReverseIterator.html">JsReverseIterator</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/public/tree-map.js~TreeMap.html">TreeMap</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/public/tree-multimap.js~TreeMultiMap.html">TreeMultiMap</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/public/tree-multiset.js~TreeMultiSet.html">TreeMultiSet</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/public/tree-set.js~TreeSet.html">TreeSet</a></span></span></li>
</ul>
</div>
</nav>

<div class="content" data-ice="content"><div class="header-notice">
  <div data-ice="importPath" class="import-path"><pre class="prettyprint"><code data-ice="importPathCode">import {Iterator} from &apos;<span><a href="file/src/public/iterators.js.html#lineNumber84">jstreemap/src/public/iterators.js</a></span>&apos;</code></pre></div>
  <span data-ice="access">public</span>
  <span data-ice="kind">class</span>
  
  
  
  <span data-ice="source">| <span><a href="file/src/public/iterators.js.html#lineNumber84">source</a></span></span>
</div>

<div class="self-detail detail">
  <h1 data-ice="name">Iterator</h1>

  

  
  
  <div class="flat-list" data-ice="extendsChain"><h4>Extends:</h4><div><span><a href="class/src/public/iterators.js~BaseIterator.html">BaseIterator</a></span> &#x2192; Iterator</div></div>
  
  
  
  
  
  

  
  
  <div class="description" data-ice="description"><p>STL-like forward iterator. It&apos;s more verbose than ES6 iterators, but allows iteration over any part of the container</p>
</div>
  

  

  <div data-ice="exampleDocs">
    <h4>Example:</h4>
    
  <div class="example-doc" data-ice="exampleDoc">
      
      <pre class="prettyprint source-code"><code data-ice="exampleCode">let m = new TreeMap();
...
for (let it = m.begin(); !it.equals(m.end()); it.next()) {
  console.log(`key: ${it.key}, value: ${it.value}`);
}</code></pre>
    </div>
</div>

  

  
</div>



<div data-ice="constructorSummary"><h2>Constructor Summary</h2><table class="summary" data-ice="summary">
  <thead><tr><td data-ice="title" colspan="3">Public Constructor</td></tr></thead>
  <tbody>
  
  <tr data-ice="target">
    <td>
      <span class="access" data-ice="access">public</span>
      
      
      
      <span class="override" data-ice="override"></span>
    </td>
    <td>
      <div>
        <p>
          
          
          
          <span class="code" data-ice="name"><span><a href="class/src/public/iterators.js~Iterator.html#instance-constructor-constructor">constructor</a></span></span><span class="code" data-ice="signature">(args: <span>*</span>)</span>
        </p>
      </div>
      <div>
        
        
        <div data-ice="description"><p>There are 3 ways to construct an iterator:</p>
</div>
      </div>
    </td>
    <td>
      
      
    </td>
  </tr>
</tbody>
</table>
</div>

<div data-ice="methodSummary"><h2>Method Summary</h2><table class="summary" data-ice="summary">
  <thead><tr><td data-ice="title" colspan="3">Public Methods</td></tr></thead>
  <tbody>
  
  <tr data-ice="target">
    <td>
      <span class="access" data-ice="access">public</span>
      
      
      
      <span class="override" data-ice="override"></span>
    </td>
    <td>
      <div>
        <p>
          
          
          
          <span class="code" data-ice="name"><span><a href="class/src/public/iterators.js~Iterator.html#instance-method-next">next</a></span></span><span class="code" data-ice="signature">()</span>
        </p>
      </div>
      <div>
        
        
        <div data-ice="description"><p>Replaces node reference with the reference of the next node in the container.</p>
</div>
      </div>
    </td>
    <td>
      
      
    </td>
  </tr>
<tr data-ice="target">
    <td>
      <span class="access" data-ice="access">public</span>
      
      
      
      <span class="override" data-ice="override"></span>
    </td>
    <td>
      <div>
        <p>
          
          
          
          <span class="code" data-ice="name"><span><a href="class/src/public/iterators.js~Iterator.html#instance-method-prev">prev</a></span></span><span class="code" data-ice="signature">()</span>
        </p>
      </div>
      <div>
        
        
        <div data-ice="description"><p>Replaces node reference with the reference of the previous node in the container
Can be used for manual reverse iteration over a range of key-value pairs.</p>
</div>
      </div>
    </td>
    <td>
      
      
    </td>
  </tr>
</tbody>
</table>
</div>

<div class="inherited-summary" data-ice="inheritedSummary"><h2>Inherited Summary</h2><table class="summary" data-ice="summary">
  <thead><tr><td data-ice="title" colspan="3"><span class="toggle closed"></span> From class <span><a href="class/src/public/iterators.js~BaseIterator.html">BaseIterator</a></span></td></tr></thead>
  <tbody>
  
  <tr data-ice="target">
    <td>
      <span class="access" data-ice="access">public</span>
      
      
      
      <span class="override" data-ice="override"></span>
    </td>
    <td>
      <div>
        <p>
          
          
          
          <span class="code" data-ice="name"><span><a href="class/src/public/iterators.js~BaseIterator.html#instance-method-equals">equals</a></span></span><span class="code" data-ice="signature">(rhs: <span><a href="class/src/public/iterators.js~BaseIterator.html">BaseIterator</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></span>
        </p>
      </div>
      <div>
        
        
        <div data-ice="description"><p>Two iterators are considered to be equal if they point to the same node of the same container</p>
</div>
      </div>
    </td>
    <td>
      
      
    </td>
  </tr>
</tbody>
</table>
</div>



<div data-ice="constructorDetails"><h2 data-ice="title">Public Constructors</h2>

<div class="detail" data-ice="detail">
  <h3 data-ice="anchor" id="instance-constructor-constructor">
    <span class="access" data-ice="access">public</span>
    
    
    
    
    
    <span class="code" data-ice="name">constructor</span><span class="code" data-ice="signature">(args: <span>*</span>)</span>
    <span class="right-info">
      
      
      <span data-ice="source"><span><a href="file/src/public/iterators.js.html#lineNumber105">source</a></span></span>
    </span>
  </h3>

  
  
  
  <div data-ice="description"><p>There are 3 ways to construct an iterator:</p>
<ol>
<li>Using a node and a container</li>
<li>Copy constructor / clone</li>
<li>Copy constructor / clone from ReverseIterator instance</li>
</ol>
</div>

  <div data-ice="override"><h4>Override:</h4><span><a href="class/src/public/iterators.js~BaseIterator.html#instance-constructor-constructor">BaseIterator#constructor</a></span></div>

  <div data-ice="properties"><div data-ice="properties">
  <h4 data-ice="title">Params:</h4>
  <table class="params">
    <thead>
    <tr><td>Name</td><td>Type</td><td>Attribute</td><td>Description</td></tr>
    </thead>
    <tbody>
    
    <tr data-ice="property" data-depth="0">
      <td data-ice="name" class="code" data-depth="0">args</td>
      <td data-ice="type" class="code"><span>*</span></td>
      <td data-ice="appendix"></td>
      <td data-ice="description"></td>
    </tr>
</tbody>
  </table>
</div>
</div>

  

  

  

  

  

  <div data-ice="example">
    <h4>Example:</h4>
    
  <div class="example-doc" data-ice="exampleDoc">
      
      <pre class="prettyprint source-code"><code data-ice="exampleCode">// Using a node and a container
let it = new Iterator(node, container);

// Copy constructor / clone
let it1 = new Iterator(node, container);
let it2 = new Iterator(it1);

// Copy constructor / clone from ReverseIterator instance
let it1 = new ReverseIterator(node, container);
let it2 = new Iterator(it1);</code></pre>
    </div>
</div>

  

  
  
</div>
</div>

<div data-ice="methodDetails"><h2 data-ice="title">Public Methods</h2>

<div class="detail" data-ice="detail">
  <h3 data-ice="anchor" id="instance-method-next">
    <span class="access" data-ice="access">public</span>
    
    
    
    
    
    <span class="code" data-ice="name">next</span><span class="code" data-ice="signature">()</span>
    <span class="right-info">
      
      
      <span data-ice="source"><span><a href="file/src/public/iterators.js.html#lineNumber144">source</a></span></span>
    </span>
  </h3>

  
  
  
  <div data-ice="description"><p>Replaces node reference with the reference of the next node in the container.
Can be used for manual iteration over a range of key-value pairs.</p>
</div>

  

  <div data-ice="properties">
</div>

  

  

  

  

  

  <div data-ice="example">
    <h4>Example:</h4>
    
  <div class="example-doc" data-ice="exampleDoc">
      
      <pre class="prettyprint source-code"><code data-ice="exampleCode">let m = new TreeMap();
... // add key-value pairs., using numbers as keys
let from = t.lowerBound(0);
let to = t.upperBound(50);
let it = from;
while (!it.equals(to)) {
  console.log(it.key);
  it.next();
}</code></pre>
    </div>
</div>

  

  
  
</div>
<div class="detail" data-ice="detail">
  <h3 data-ice="anchor" id="instance-method-prev">
    <span class="access" data-ice="access">public</span>
    
    
    
    
    
    <span class="code" data-ice="name">prev</span><span class="code" data-ice="signature">()</span>
    <span class="right-info">
      
      
      <span data-ice="source"><span><a href="file/src/public/iterators.js.html#lineNumber165">source</a></span></span>
    </span>
  </h3>

  
  
  
  <div data-ice="description"><p>Replaces node reference with the reference of the previous node in the container
Can be used for manual reverse iteration over a range of key-value pairs.</p>
</div>

  

  <div data-ice="properties">
</div>

  

  

  

  

  

  <div data-ice="example">
    <h4>Example:</h4>
    
  <div class="example-doc" data-ice="exampleDoc">
      
      <pre class="prettyprint source-code"><code data-ice="exampleCode">let m = new TreeMap();
... // add key-value pairs., using numbers as keys
let from = t.lowerBound(0);
let to = t.upperBound(50);
let it = to;
while (!it.equals(from)) {
  it.prev();
  console.log(it.key);
}</code></pre>
    </div>
</div>

  

  
  
</div>
</div>
</div>

<footer class="footer">
  Generated by <a href="https://esdoc.org">ESDoc<span data-ice="esdocVersion">(1.0.4)</span><img src="./image/esdoc-logo-mini-black.png"></a>
</footer>

<script src="script/search_index.js"></script>
<script src="script/search.js"></script>
<script src="script/pretty-print.js"></script>
<script src="script/inherited-summary.js"></script>
<script src="script/test-summary.js"></script>
<script src="script/inner-link.js"></script>
<script src="script/patch-for-local.js"></script>
</body>
</html>
